<template>
    <framework title="法律著作" second-title="Legal works" :bg="require('@/assets/img/legal-header.png')"
               :path="[{name:'法律著作',path:'/legalWorks'}]" :wrap-style="{background: '#FFFFFF'}">
        <div class="sq_legal">
            <div class="list_box">
                <div class="box" v-for="(it,index) in boxList" :key="index">
<!--                    <div class="left" :style="{background:`url('${it.img}')`}">-->
<!--                    </div>-->
                    <div class="left">
                        <img :src="it.img" alt="">
                    </div>

                    <div class="right">
                        <div class="title f2">{{ it.title }}</div>
                        <div class="right-content">
                            <div class="content f3" v-html="it.introduce.replace(/<img.*?(?:>|\/>)/gi,'')">
                            </div>
                        </div>
                        <button @click="viewDetails(it.id)">{{ $t('index.book.detailsButton') }}</button>
                    </div>

                </div>
            </div>
        </div>
    </framework>
</template>

<script>
import framework from '@/components/framework'

import {useRouter} from 'vue-router'
//法律著作
export default {
    name: "LegalWorks",
    components: {framework},
    data() {
        return {
            boxList: []
        }
    },
    async mounted() {
        let data = await this.$http.get('/lawArticle/list')
        this.boxList = data.page.list
    },

    setup() {
        const router = useRouter()
        const viewDetails = (id) => {
            router.push({
                path: 'allDetails', query: {
                    type: 3,
                    id: id
                }
            })
        }
        return {
            viewDetails
        }
    }
}
</script>

<style scoped lang="less">
.sq_legal {
    .list_box {
        display: grid;
        grid-template-columns: 1fr 1fr;
        grid-gap: 30px;
        padding: 120px 0;

        .box {
            background: #FFFFFF;
            display: flex;
            flex-direction: row;
            padding: 20px;
            .left {
                width: 219px;
                height: 267px;
                img{
                    display: block;
                    width: 100%;
                    vertical-align: middle;
                }
            }
            //
            //.left:after{
            //    content: '';
            //    display: block;
            //    padding-top: 150%;
            //}
            .right {
                margin-left: 45px;
                width: 60%;
                display: flex;
                flex-direction: column;
                justify-content: space-between;

                .date {
                    height: 30px;
                    font-weight: 400;
                    line-height: 29px;
                    color: #707070;

                    span {
                        padding: 0 20px;
                        background: #FFFFFF;
                    }

                    hr {
                        margin-top: -15px;
                        width: 100%;
                    }
                }

                .title {
                    font-weight: 400;
                }

                .content {
                    font-weight: 400;
                    line-height: 29px;
                    text-indent: 2rem;
                    overflow: hidden;
                    word-break: break-all;
                    display: -webkit-box;
                    -webkit-line-clamp: 7; /* 指定行数*/
                    -webkit-box-orient: vertical;
                }

                button {
                    width: 100px;
                    height: 40px;
                    border: 1px solid #855949;
                    border-radius: 7px;
                    cursor: pointer;
                    background: none;
                    color: #993C1A;
                }
            }
        }


    }

}

</style>

<style lang="less">
@media screen and (min-width: 0px) and (max-width: 680px) {
    #app {
        .sq_legal {
            .list_box {
                padding: 0;
                display: block;

                .box {
                    margin-top: 10px;
                    border: none;
                    padding: 5px;

                    .left {
                        width: 100%;
                    }

                    .right {
                        width: 100%;

                        button {
                            height: 40px;
                            width: 100%;
                            margin-top: 10px;
                        }
                    }
                }
            }
        }
    }
}
</style>
